package ch.ti.bfh.app.loodel.web.model;

import org.primefaces.model.ScheduleEvent;

import java.util.Date;

public class LoodelScheduleEvent implements ScheduleEvent {

    private final ScheduleEvent scheduleEvent;

    private boolean selectedEvent;

    private boolean votedEvent;

    private boolean clickable;

    private Boolean acceptedEvent;

    public LoodelScheduleEvent(ScheduleEvent scheduleEvent, boolean selectedEvent, boolean votedEvent, Boolean acceptedEvent, boolean clickable1) {
        this.scheduleEvent = scheduleEvent;
        this.selectedEvent = selectedEvent;
        this.votedEvent = votedEvent;
        this.acceptedEvent = acceptedEvent;
        this.clickable = clickable1;
    }


    @Override
    public String getId() {
        return scheduleEvent.getId();
    }

    @Override
    public void setId(String id) {
        scheduleEvent.setId(id);
    }

    @Override
    public Object getData() {
        return scheduleEvent.getData();
    }

    @Override
    public String getTitle() {
        return scheduleEvent.getTitle();
    }

    @Override
    public Date getStartDate() {
        return scheduleEvent.getStartDate();
    }

    @Override
    public Date getEndDate() {
        return scheduleEvent.getEndDate();
    }

    @Override
    public boolean isAllDay() {
        return scheduleEvent.isAllDay();
    }

    @Override
    public String getStyleClass() {
        StringBuilder stringBuilder = new StringBuilder();
        if (acceptedEvent != null && acceptedEvent) {
            stringBuilder.append(votedEvent ? "accepted-voted-event" : "accepted-unvoted-event");
        } else {
            stringBuilder.append(votedEvent ? "voted-event" : "unvoted-event");
        }
        stringBuilder.append(" ");
        stringBuilder.append(selectedEvent ? "selected-event" : "unselected-event");
        stringBuilder.append(" ");
        stringBuilder.append(isEditable() || clickable ? "action-event" : "");
        return stringBuilder.toString();
    }

    @Override
    public boolean isEditable() {
        return scheduleEvent.isEditable();
    }

    public void setSelectedEvent(boolean selectedEvent) {
        this.selectedEvent = selectedEvent;
    }
}
